package com.dq.utils;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import org.thymeleaf.util.DateUtils;

import java.util.Date;
import java.util.Map;

public class JwtUtil {
    private static final String KEY = "gaoruifeng";
	//接收业务数据,生成token并返回
    public static String genToken(Map<String, Object> claims) {
        return JWT.create()
                .withClaim("claims", claims)//将map集合（用户id，用户名）存入token作为载荷
                .withExpiresAt(new Date(System.currentTimeMillis() + 1000 * 60 * 60 ))//token失效时间1小时
                .sign(Algorithm.HMAC256(KEY));//以KEY作为token密钥
    }




}
